package com.yc.jpyy.mobile.controller;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yc.jpyy.base.bean.RestResponse;
import com.yc.jpyy.base.config.Config;
import com.yc.jpyy.base.controller.BaseController;
import com.yc.jpyy.mobile.dao.AdminDao;
import com.yc.jpyy.mobile.service.AdminService;

@Controller
@RequestMapping(value = "/admin")
public class GetSlackLearnStudent extends BaseController {
	@Autowired
	private AdminService adminService;

	@Autowired
	private AdminDao adminDao;
	private static Logger logger = LoggerFactory
			.getLogger(AdminLoginController.class);

	/**
	 * 获取怠学学生信息
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/getSlackLearnStudent", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
	public @ResponseBody String getSlackLearnStudent(HttpServletRequest request)
			throws UnsupportedEncodingException {

		RestResponse response = new RestResponse();
		request.setCharacterEncoding("UTF-8");

		try {
			// 驾校Id
			String driverId = request.getParameter("driverId");
			if (driverId != null && !driverId.isEmpty()) {
				Map<String,Object> paramsmap = new HashMap<String,Object>();
				paramsmap.put("driverId",driverId);
				paramsmap.put("imgUrl",Config.getImageAddress());
				response = adminService.getSlackLearnStudent(paramsmap, response);
			} else {
				response.setErrorcode(1);
				response.setMessage("缺少必填字段！");
			}
		} catch (Exception e) {
			logger.info("getSlackLearnStudent:" + e.toString());
			response.setReturnMsg(1, "获取怠学信息失败！");
		} finally {
			return response.toJSON();
		}
	}

}
